<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        *{
            margin: 0;padding: 0;
        }
        #app{
            width: 96%;
            margin: auto;
        }
        .input{
            margin-top: 10px;
            display: flex;
            justify-content: space-between;
        }
        .input input{
            height: 40px;
            width: 80%;
            border: none;
            outline: none;
            padding-left: 20px;
            background-color: #f5f5f5;
        }
        .input span{
            line-height: 40px;
            margin: 0 10px;
        }
        .suammry {
            margin: 10px 0;
            height: 34px; 
            line-height: 25px;
        }
        .suammry span{
            height: 26px;
            margin-right: 14px;
            padding: 2px 13px;
            display: inline-block;
            border-radius: 5px;
            background-color: lightseagreen;
            color: white;
            font-size: 14px;
        }
        .box .list .li{
            color: white;
            display: flex;
            align-items: center;
            justify-content: space-between;
            text-align: left;
            padding-left: 10px;
            margin: 10px 0;
            background-color: lightseagreen;
            line-height: 40px;
        }
        .box .list .li span{
            width: 25%;
            display: inline-block;
            margin-right: 10px;
        }
        .box .list .li span:nth-child(2){
            width: 5%;
        }
        .box .list .li span:nth-child(4){
            text-align: right;
        }
        .empty{
            text-align: center;
            padding: 50px 0;
        }
        #app .box .unfinished{
            background-color: red;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="input">
            <input type="text" placeholder="输入任务名称" v-model="text"> 
            <span @click="add">增加</span>
        </div>
        <div class="suammry">
            <span>全部任务( {{list.length}} )</span>
            <span>已完成( {{list.length-unFinishCount}} )</span>
            <span>未完成( {{unFinishCount}} )</span>
        </div>
        <h3>任务列表</h3>
        <div class="box">
            <div class="list" v-for="(item,index) in list" >
                <div class="li" :class="{ unfinished: item.status==false }" :key="index">
                    <input  type="checkbox" :checked="item.status"  @click="changeStatus(item)">
                    <span>{{item.id}}</span>
                    <span>{{item.name}}</span>
                    <span @click="del(item,index)">删除</span>
                </div>
            </div>
            <div v-show="list.length==0" class="empty">
                任务列表为空,请添加一个任务!
            </div>
        </div>
    </div>
</body>
</html>
<script src="./vue-2.5.21.js"></script>
<script src="./TodoList.js"></script>